import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { PositionGroupVO, PositionGroupForm, PositionGroupQuery } from '@/leadmall/api/positionGroup/types';

/**
 * 查询权限分组和岗位的关联列表
 * @param query
 * @returns {*}
 */

export const listPositionGroup = (query?: PositionGroupQuery): AxiosPromise<PositionGroupVO[]> => {
  return request({
    url: PORT +'/leadmall/positionGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询权限分组和岗位的关联详细
 * @param pid
 */
export const getPositionGroup = (pid: string | number): AxiosPromise<PositionGroupVO> => {
  return request({
    url: PORT +'/leadmall/positionGroup/' + pid,
    method: 'get'
  });
};

/**
 * 新增权限分组和岗位的关联
 * @param data
 */
export const addPositionGroup = (data: PositionGroupForm) => {
  return request({
    url: PORT +'/leadmall/positionGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改权限分组和岗位的关联
 * @param data
 */
export const updatePositionGroup = (data: PositionGroupForm) => {
  return request({
    url: PORT +'/leadmall/positionGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除权限分组和岗位的关联
 * @param pid
 */
export const delPositionGroup = (pid: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/positionGroup/' + pid,
    method: 'delete'
  });
};
